<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/common/includes.jsp" %>
<%@ include file="/WEB-INF/view/inc.jsp" %>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>



    </style>
</head>
<body>

<div class="dialog_form">
    <form  method="post" id="fm" action="<%=contextPath%>/cookbook/saveAndUpdate" enctype="multipart/form-data"accept="image/gif, image/jpeg,image/jpg, image/png">
        <input type="hidden" name="id" value="${cookbook.id}"/>

        <div class="dialog_item">
            <label>菜谱名称:</label>
            <input  name="cookbookName" class="no-space easyui-textbox" required="true"
                    validType="length[1,50]" value="${cookbook.cookbookName}"><span>*</span>
        </div>
        <div class="dialog_item">
            <label>点评:</label>
            <input name="comments" class="easyui-textbox" data-options="multiline:true" validType="length[1,1000]" style="width:300px;height:100px" value="${cookbook.comments}">
        </div>
        <div class="dialog_item">
            <label>美味体验:</label>
            <input name="experience" class="easyui-textbox" data-options="multiline:true" validType="length[1,1000]" style="width:300px;height:100px" value="${cookbook.experience}">
        </div>
        <div class="dialog_item">
            <label>养生必读:</label>
            <input name="health" class="easyui-textbox" data-options="multiline:true" validType="length[1,1000]" style="width:300px;height:100px" value="${cookbook.health}">
        </div>
        <div class="dialog_item">
            <label>状态:</label>
            <input name="sex" editable="false" value="${cookbook.status}"
                   class="easyui-combobox" data-options="valueField : 'code',
	    						textField : 'name', url:'<%=contextPath%>/sys/codeItems/byCategoryCode?categoryCode=status',
								panelHeight:'auto'
							">
        </div>
        <br/>
        <div class="dialog_item">
        <label id="title">图片预览:</label>
        <div style="width: 800px;"id="tpyl">
            <c:if test="${not empty StringArr }">
                <c:forEach items="${StringArr}" var="img">

                    <div class="img_Div" id="${fn:substring(img,1,32)}" style="float: left;margin-left: 3px;margin-bottom: 3px;">
                        <div class="img_del"  onclick="delId('${fn:substring(img,1,32)}')"  >
                            <img class="close" src="/jslib/common/images/button/close.png"  style="width: 10px;float: right;" >
                        </div>
                        <img class="img-square" src="/file/${img}" style="width: 100px;">
                        <input name="img" type="hidden" value="${img}">
                    </div>

                </c:forEach>
            </c:if>
        </div>
        </div>
        <div class="dialog_item">
            <label>图片:</label>
            <input  name="fileToUpload" id="fileToUpload" type="file" multiple="true" <%--class="easyui-filebox"--%>  validType="length[1,1000]" style="width: 200px;" value="${cookbook.img}">
            <input type="button" value="上传" onclick="sy_uploadImg()">
        </div>

        <div class="img_Div_hidden" id="clone" style="float: left;margin-left: 3px;margin-bottom: 3px; visibility: hidden">
            <div class="img_del"  onclick="delImg()"  >
                <img class="close" src="/jslib/common/images/button/close.png"  style="width: 10px;float: right;" >
            </div>
            <img class="img-square" src="" style="width: 100px;">
            <input name="img" type="hidden" value="">
        </div>

    </form>
</div>
<script>
    //成功后处理方法(默认)
    var successFun = function(result) {
        debugger;
        if (result == "0") {
            parent.$.messager.alert("错误", "请选择上传的图片");
        } else if (result == "1") {
            parent.$.messager.alert("错误", "有单个文件超过5M");
        } else {
            var imgArray = result.split(",");
            $.each(imgArray, function (i, item) {
                var id = item.substring(0, 32);
                var img_Div = $("<div class='img_Div' id=" + id + "  style='float: left;margin-left: 3px;margin-bottom: 3px; '/>");
                var del_But_Div = $("<div class='img_del_button_div' onclick='delId(\"" + id + "\")'  />");
                var but_Img = $("<img src='/jslib/common/images/button/close.png'  style='width: 10px;float: right;'>");
                var result_Img = $(" <img class='img_result' src='/file/" + item + " 'style='width: 100px;'>");
                var input = $("<input name='img' type='hidden' value=" + item + ">");
                del_But_Div.append(but_Img);
                img_Div.append(del_But_Div);
                img_Div.append(result_Img);
                img_Div.append(input);
                $("#tpyl").append(img_Div);//图片预览Div
            })
        }
    }
</script>
</body>

</html>
